package com.edu.controller;


import com.edu.bean.Book;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class BookController {
    /**
     *   url级别的参数  用 一个基本数据类型接受
     */
/*    @RequestMapping("/book/{id}")
    public String showBook(@PathVariable("id") int bookId){
        System.out.println("查询了id为"+bookId+"的书");
        return "/index.jsp";
    }*/

    /**
     *  url级别的参数 用 一个对象来接受
     */

    @RequestMapping("/book/{bookId}")
    public String showBook(Book book){
        System.out.println(book);
        System.out.println("查询了id为"+book.getBookId()+"的书");
        return "/index.jsp";
    }


//    @RequestMapping("{wId}/book/{bId}")
//    public String showBook2(@PathVariable("wId") int wId,@PathVariable("bId") int bId){
//        System.out.println("作者id为"+wId);
//        System.out.println("查询了id为"+bId+"的书");
//        return "/index.jsp";
//    }

    @RequestMapping("{bookWriter}/book/{bookId}")
    public String showBook3(Book book){
        System.out.println(book);
        return "/index.jsp";
    }
}
